<?php
	function followProjectTag($record, $requestContext)
	{
		$sessionInfo = $requestContext->sessionInfo;
		if (isset($record->params->relation_kind) && $record->params->relation_kind != null) {
			return "[$record->params->relation_kind]";
		}
		$retval = '<a href="'. controller_base_path($requestContext).'/Connection/follow?type=Project&sid='.$record->sid.'">Follow</a>';
		$retval = $retval. ' | <a href="'. controller_base_path($requestContext).'/Project/requestjoin?projectSid='.$record->sid.'&userSid='.$sessionInfo->userInfo['userSid'].'&type=collab">Join</a>';
		return $retval;
	}
	
	function connectUserTag($record, $requestContext)
	{
		$sessionInfo = $requestContext->sessionInfo;
		// params->member_type was obtained by doing a custom SQL query at the server.
		if (isset($record->params->member_type)) {
			if ($record->params->member_type == 'owner') {
				return '[MINE]';// it's mine, show nothing
			} else {
				return "[$record->params->member_type]";
			}
		}
		$retval = '<a href="'. controller_base_path($requestContext).'/Connection/invite?coUserSid='.$record->sid.'">Connect</a> ';
		if ( isset($sessionInfo->currentProjectSid) && $sessionInfo->currentProjectSid > 0) {
			$retval = $retval.' | <a href="'. controller_base_path($requestContext).'/Project/invite?projectSid='.$sessionInfo->currentProjectSid.'&userSid='.$record->sid.'&type=collab">Invite to Project</a>';
		}
		return $retval;
	}
?>

							<form class="form-horizontal" id="FormProfileSearch" name="FormProfileSearch" method="post" action="<?php echo controller_base_path($requestContext); ?>/Search/profile"  >
								<fieldset>
									<legend>Search criteria</legend>
									<div class="control-group">
										<label class="control-label" for="name">Name</label>
										<div class="controls">
											<input type="text" id="nameLike" name="nameLike" 
												value="<?php echo Util_Data::getValueOf($criteria, 'nameLike'); ?>" />
										</div>
									</div>

									<div class="control-group">
										<label class="control-label" for="currentLocation">Current Location</label>
										<div class="controls">
											<input type="text" id="currentLocation" name="currentLocation" 
												value="<?php echo Util_Data::getValueOf($criteria, 'currentLocation'); ?>" />
										</div>
									</div>
									<!--
									<div class="control-group">
										<label class="control-label" for="hometown">Hometown</label>
										<div class="controls">
											<input type="text" id="hometown" name="hometown" 
												value="<?php echo Util_Data::getValueOf($criteria, 'hometown'); ?>" />
										</div>
									</div>
									 -->
									<div class="control-group">
										<label class="control-label" for="gender">Gender</label>
										<div class="controls">
											<?php echo Form::select('gender', array("m"=>"Male", "f"=>"Female", ""=>"Any"), Util_Data::getValueOf($criteria, 'gender')); ?>
										</div>
									</div>

									<!--
									<div class="control-group">
										<label class="control-label" for="highlight">Highlight</label>
										<div class="controls">
											<textarea id="goals" name="highlight" class="span12"><?php echo Util_Data::getValueOf($criteria, 'highlight'); ?></textarea>
										</div>
									</div>
									<div class="control-group">
										<label class="control-label" for="goals">Goals</label>
										<div class="controls">
											<textarea id="goals" name="goals" class="span12"><?php echo Util_Data::getValueOf($criteria, 'goals'); ?></textarea>
										</div>
									</div>
		 -->
									<div class="control-group">
										<label class="control-label" for="status">Status</label>
										<div class="controls">
											<?php echo Form::select('status', array("1"=>"Available", "0"=>"Not Available"), Util_Data::getValueOf($criteria, 'status')); ?>
										</div>
									</div>
									<div class="control-group">
										<label class="control-label" for="timeCommitment">Time Commitment</label>
										<div class="controls">
											<?php echo Form::select('timeCommitment', array(3,5,6,9,10,12,15,18,20,25,30,35,40,50,60), Util_Data::getValueOf($criteria, 'timeCommitment')); ?> min. hrs per week
										</div>
									</div>
									<div class="control-group">
										<label class="control-label" for="languageTagNamesCsv">Languages</label>
										<div class="controls">
											<input type="text" id="languageTagNamesCsv" name="languageTagNamesCsv"
													value="<?php echo Util_Data::getValueOf($criteria, 'languageTagNamesCsv'); ?>" />
										</div>
									</div>
									<div class="control-group">
										<label class="control-label" for="skillTagNamesCsv">Skills</label>
										<div class="controls">
											<input type="text" id="skillTagNamesCsv" name="skillTagNamesCsv"
													value="<?php echo Util_Data::getValueOf($criteria, 'skillTagNamesCsv'); ?>" />
										</div>
									</div>
									<div class="control-group">
										<label class="control-label" for="interestTagNamesCsv">Interests</label>
										<div class="controls">
											<input type="text" id="interestTagNamesCsv" name="interestTagNamesCsv"
													value="<?php echo Util_Data::getValueOf($criteria, 'interestTagNamesCsv'); ?>" />
										</div>
									</div>
									<div class="control-group">
										<label class="control-label" for="inlineCheckboxes">I want to </label>
										<div class="controls">
											<label class="checkbox inline">
												<input type="checkbox" name="wantTo_pursue" value="1" <?php echo Util_Data::hasBitFlagSet($criteria, 'wantTo', 1) ? 'checked="checked"' :'' ; ?> />Pursue goal
											</label>
											<label class="checkbox inline">
												<input type="checkbox" name="wantTo_mentor" value="2" <?php echo Util_Data::hasBitFlagSet($criteria, 'wantTo', 2) ? 'checked="checked"' :'' ; ?> />Mentor/Advise
											</label>
											<label class="checkbox inline">
												<input type="checkbox" name="wantTo_collaborate" value="4" <?php echo Util_Data::hasBitFlagSet($criteria, 'wantTo', 4) ? 'checked="checked"' :'' ; ?> />Collaborate
											</label>
										</div>
									</div>

									<div class="control-group">
										<div class="controls">
											<button type="submit" class="btn">Search</button>
										</div>
									</div>

								</fieldset>
							</form>

							<h4>Search Result</h4>
							
<?php 
if ( isset($searchResult) && $searchResult != null) {
	foreach ($searchResult->entries as $hitEntry) {
	$record = $hitEntry->record; ?>
							<div style="width:100%; display:inline-block;">
								<img src="<?php echo profile_img_url( $record->creatorDto->profileImageSid, 40) ?>" style="float:left; padding:5px">
								<div style="margin-right:50px"><b><a href="<?php echo controller_base_path($requestContext).'/Profile?userSid='.$record->creatorSid;?>"><?php echo $record->creatorDto->displayName; ?></a></b> from <?php echo $record->currentLocation; ?><br />
									<?php echo $record->highlight; ?>
									<p>Skills: <?php echo $record->skillTagNamesCsv; ?></p>
									<div style="float:right"><?php echo connectUserTag($record, $requestContext); ?></div>
								</div>
								<br />
							</div>
<?php } // entries 
} // if ?>
							
					